{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "GPT2-Pytorch.ipynb",
      "version": "0.3.2",
      "provenance": [],
      "collapsed_sections": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "accelerator": "GPU"
  },
  "cells": [
    {
      "metadata": {
        "id": "4L7HpNaFHO5D",
        "colab_type": "code",
        "outputId": "a97fd9ea-0390-473c-f96a-2b0e32e70cca",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 373
        }
      },
      "cell_type": "code",
      "source": [
        "!git clone https://github.com/graykode/gpt-2-Pytorch\n",
        "%cd gpt-2-Pytorch\n",
        "!curl --output gpt2-pytorch_model.bin https://s3.amazonaws.com/models.huggingface.co/bert/gpt2-pytorch_model.bin\n",
        "!pip install -r requirements.txt"
      ],
      "execution_count": 1,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Cloning into 'gpt-2-Pytorch'...\n",
            "remote: Enumerating objects: 51, done.\u001b[K\n",
            "remote: Counting objects: 100% (51/51), done.\u001b[K\n",
            "remote: Compressing objects: 100% (40/40), done.\u001b[K\n",
            "remote: Total 51 (delta 15), reused 44 (delta 9), pack-reused 0\u001b[K\n",
            "Unpacking objects: 100% (51/51), done.\n",
            "/content/gpt-2-Pytorch\n",
            "  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\n",
            "                                 Dload  Upload   Total   Spent    Left  Speed\n",
            "100  522M  100  522M    0     0  77.7M      0  0:00:06  0:00:06 --:--:-- 81.3M\n",
            "Collecting fire>=0.1.3 (from -r requirements.txt (line 1))\n",
            "  Downloading https://files.pythonhosted.org/packages/5a/b7/205702f348aab198baecd1d8344a90748cb68f53bdcd1cc30cbc08e47d3e/fire-0.1.3.tar.gz\n",
            "Collecting regex==2017.4.5 (from -r requirements.txt (line 2))\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/36/62/c0c0d762ffd4ffaf39f372eb8561b8d491a11ace5a7884610424a8b40f95/regex-2017.04.05.tar.gz (601kB)\n",
            "\u001b[K    100% |████████████████████████████████| 604kB 26.2MB/s \n",
            "\u001b[?25hCollecting gpt2-pytorch_model.bin (from -r requirements.txt (line 3))\n",
            "\u001b[31m  Could not find a version that satisfies the requirement gpt2-pytorch_model.bin (from -r requirements.txt (line 3)) (from versions: )\u001b[0m\n",
            "\u001b[31mNo matching distribution found for gpt2-pytorch_model.bin (from -r requirements.txt (line 3))\u001b[0m\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "metadata": {
        "id": "he_YiEC9T6-D",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 205
        },
        "outputId": "58e3f04e-905a-4adf-fd0c-98c682abe9d2"
      },
      "cell_type": "code",
      "source": [
        "!python main.py --text \"Once when I was six years old I saw a magnificent picture in a book, called True Stories from Nature, about the primeval forest.\""
      ],
      "execution_count": 2,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Namespace(batch_size=-1, length=-1, nsamples=1, seed=0, temperature=1, text='Once when I was six years old I saw a magnificent picture in a book, called True Stories from Nature, about the primeval forest.', top_k=0, unconditional=False)\n",
            "Once when I was six years old I saw a magnificent picture in a book, called True Stories from Nature, about the primeval forest.\n",
            "[7454, 618, 314, 373, 2237, 812, 1468, 314, 2497, 257, 25023, 4286, 287, 257, 1492, 11, 1444, 6407, 18152, 422, 10362, 11, 546, 262, 6994, 2100, 8222, 13]\n",
            "100% 512/512 [00:12<00:00, 40.58it/s]\n",
            "======================================== SAMPLE 1 ========================================\n",
            " I didn't know about it until a few months later when comparing the figure of ichthyosis emblazoned on a top of mushroom scales with misinformation spread by reputable population labs that discovered breeders of various breeds and classes of plants that are more closely related to these plants than others, at least according to their interpretation of what was being observed, very closely adapted to replace the need for the invasive species, hence the perception that only some had even arrived where the original frontier dogs would not. A few good photos were taken of lumps hooked around short arelets, showing far more frequently than others. The large puff-thraps (chloroxy pickshares) that have grown up very near Mare Crosloquifroides: a species using the word to export its products frepeace, far more than it had acquired at Mare Crosloquifroides. The coffee fennel (pelleaphrotechus) has got several, distinct markings in particular. The pinks were some from bloom and others from tame stages. Again, almost, all the people of these flocks experienced this species on an uneventful day.\n",
            "\n",
            "It strays to the story of Brammas Nostalgia made popular by that particular years-old-islet. It told a incurable and unfathomable story about strong women abused without violence or the death call of the grand poet who so loved an East Asian wife in spite of violent boyfriends who'd filiated her, destroyed wife, and threatened her on the street (and still \"Rammas Sadasta\" period) with a triangle wrapped around her finger, which the common thief would wrap around an animal's hand, regardless of true love or it to shaving half of her bitten pink cat's back, and would wrap herself in a stuffed dog-sweat sack that Kimi visited when she went to America with a crush on her black-muscled shoes or on her Manchester level Stade de Pau (Date Of Birth). The Lions Superinformations Black Pockets grew on pilgrimage to Calais somewhere to see help those soldiers and stay quiet about raging racism in our cities really makper up such stories as did Brammas Nostalgia. That all comes off as too romantic to be true in Molly Szierabich's novel Rhizopus. Remember the liberal megalopolis in BBC World-Herald Affair where the infamous Milo Yiannopoulos extravaganza featured such scenes? That do it now as a museum in Museum de Citat? It was set to\n",
            "================================================================================\n"
          ],
          "name": "stdout"
        }
      ]
    }
  ]
}